<template>
  <div class="search-form">
    <el-form :model="searchForm" inline>
      <el-form-item label="姓名">
        <el-input v-model="searchForm.name" placeholder="请输入姓名" clearable />
      </el-form-item>
      <el-form-item label="职位">
        <el-input v-model="searchForm.position" placeholder="请输入职位" clearable />
      </el-form-item>
      <el-form-item label="性别">
        <el-select v-model="searchForm.gender" placeholder="请选择性别" clearable>
          <el-option label="男" value="男" />
          <el-option label="女" value="女" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch">搜索</el-button>
        <el-button @click="handleReset">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { ref } from 'vue'

export default {
  name: 'PersonnelSearch',
  emits: ['search'],
  setup(props, { emit }) {
    const searchForm = ref({
      name: '',
      position: '',
      gender: ''
    })

    const handleSearch = () => {
      emit('search', { ...searchForm.value })
    }

    const handleReset = () => {
      searchForm.value = {
        name: '',
        position: '',
        gender: ''
      }
      emit('search', {})
    }

    return {
      searchForm,
      handleSearch,
      handleReset
    }
  }
}
</script>

<style scoped>
.search-form {
  margin-bottom: 20px;
  padding: 20px;
  background-color: #f5f7fa;
  border-radius: 4px;
}
</style> 